package com.cci.kangdao.controller;

import com.cci.kangdao.service.CourseTrainingNPBUService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Description: 课程相关信息业务
 * @Company: CTY
 * @author ljk
 * @date 2023-07-10
 * @version 1.0
 */
//复制的CourseTraining类，所有接口都增加前缀目录npbu，请求这个类里的接口都是npbu专区过来的，修改逻辑为只看到npbu的培训数据
@Controller
@RequestMapping("/npbu")
public class CourseTrainingNPBU {
	private Logger log = Logger.getLogger(this.getClass().getName());

	@Autowired
	private CourseTrainingNPBUService courseTrainingNPBUService;

	/**
	 * App获取本人课程接口
	 * @param map
	 * @return
	 */
	@RequestMapping("/getMyCourseTraining.aspx")
	public ModelAndView getMyCourseTraining(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return courseTrainingNPBUService.getMyCourseTraining(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}

	/**
	 * App获取学习营课程接口
	 * @param map
	 * @return
	 */
	@RequestMapping("/getCourseTraining.aspx")
	public ModelAndView getCourseTraining(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return courseTrainingNPBUService.getCourseTraining(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 * App搜索课程接口
	 * @param map
	 * @return
	 */
	@RequestMapping("/searchCourseTraining.aspx")
	public ModelAndView searchCourseTraining(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("request", request);
			map.put("response", response);
			return courseTrainingNPBUService.searchCourseTraining(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 *  App获取课程详细接口
	 * @param map
	 * @return
	 */
	@RequestMapping("/getCourseDetail.aspx")
	public ModelAndView getCourseDetail(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("request", request);
			map.put("response", response);
			return courseTrainingNPBUService.getCourseDetail(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 * App上传学习课程接口
	 * @param map
	 * @return
	 */
	@RequestMapping("/uploadCourseDetail.aspx")
	public ModelAndView uploadCourseDetail(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("request", request);
			map.put("response", response);
			return courseTrainingNPBUService.uploadCourseDetail(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 *  App获取课程考试接口
	 * @param map
	 * @return
	 */
	@RequestMapping("/getCourseExam.aspx")
	public ModelAndView getCourseExam(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("request", request);
			map.put("response", response);
			return courseTrainingNPBUService.getCourseExam(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 * App上传考试课题详细接口 
	 * @param map
	 * @return
	 */
	@RequestMapping("/uploadCourseExam.aspx")
	public ModelAndView uploadCourseExam(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("request", request);
			map.put("response", response);
			return courseTrainingNPBUService.uploadCourseExam(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 * App查询课程考试结果接口 
	 * @param map
	 * @return
	 */
	@RequestMapping("/getCourseExamDetail.aspx")
	public ModelAndView getCourseExamDetail(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);			
			map.put("response", response);
			return courseTrainingNPBUService.getCourseExamDetail(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}

	/**
	 * App用户修改课件状态接口 
	 * @param map
	 * @return
	 */
	@RequestMapping("/updateCourseTraining.aspx")
	public ModelAndView updateCourseTraining(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("request", request);
			map.put("response", response);
			return courseTrainingNPBUService.updateCourseTraining(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
	
	/**
	 * 获取课程是否已加入学习
	 * @param map
	 * @return
	 */
	@RequestMapping("/getCourseStudyStatus.aspx")
	public ModelAndView getCourseStudyStatus(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return courseTrainingNPBUService.getCourseStudyStatus(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);	
			
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);	
		}
		return null;
	}
}
